package com.qiniu.githubdata.service;

import com.qiniu.githubdata.mapper.DeveloperNodeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DeveloperGraphService {
    @Autowired
    private DeveloperNodeRepository developerNodeRepository;
    
    public Double calculateTalentRank(Long developerId) {
        // Base TalentRank calculation
        Double baseScore = developerNodeRepository.calculateBaseContributionScore(developerId);
        
        // Network effect multiplier (based on followers and their scores)
        Double networkMultiplier = developerNodeRepository.calculateNetworkMultiplier(developerId);
        
        // Project diversity bonus
        Double diversityBonus = developerNodeRepository.calculateProjectDiversityBonus(developerId);
        
        // Combine all factors
        return baseScore * networkMultiplier * (1 + diversityBonus);
    }
    
    public void updateDeveloperTalentRank(Long developerId) {
        Double talentRank = calculateTalentRank(developerId);
        developerNodeRepository.updateTalentRank(developerId, talentRank);
    }
}